/**
 * 初始化入驻信息详情对话框
 */
var OrgInfoInfoDlg = {
    orgInfoInfoData : {}
};

/**
 * 清除数据
 */
OrgInfoInfoDlg.clearData = function() {
    this.orgInfoInfoData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
OrgInfoInfoDlg.set = function(key, val) {
    this.orgInfoInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
    return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
OrgInfoInfoDlg.get = function(key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
OrgInfoInfoDlg.close = function() {
    parent.layer.close(window.parent.OrgInfo.layerIndex);
}


/**
 * 收集数据
 */
OrgInfoInfoDlg.collectData = function() {
    this.set('id').set('joinId').set('orgName').set('contactPeople').set('contactPhone').set('qq').set('mail').set('city').set('website').set('detAddress').set('introduce').set('companyPicUrl').set('orgTel').set('introduceKey').set('assessScore').set('searchNumber').set('infoDetail_image1').set('infoDetail_image2').set('infoDetail_image3').set('userId');
}

/**
 * 提交添加
 */
OrgInfoInfoDlg.addSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/orgInfo/add", function(data){
        Feng.success("添加成功!");
        window.parent.OrgInfo.table.refresh();
        OrgInfoInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.orgInfoInfoData);
    ajax.start();
}

/**
 * 提交修改
 */
OrgInfoInfoDlg.editSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/orgInfo/update", function(data){
        Feng.success("修改成功!");
        window.parent.OrgInfo.table.refresh();
        OrgInfoInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.orgInfoInfoData);
    ajax.start();
}

$(function() {

});
/**
 * 审核通过
 */
OrgInfoInfoDlg.pass= function() {

    var joinId = $("#joinId").val();
    var userId = $("#userId").val();
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/orgInfo/pass?id="+joinId+"&userId="+userId, function(data){
        Feng.success("修改成功!");
        window.parent.OrgInfo.table.refresh();
        OrgInfoInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.orgInfoInfoData);
    ajax.start();
}

$(function() {

});
/**
 * 审核拒绝原因
 */
OrgInfoInfoDlg.openRefuse= function(joinId,userId){
    var index = layer.open({
        type: 2,
        title: '拒绝原因',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/orgInfo/orgInfo_refuse1?joinId='+joinId+"&userId="+userId
    });
    this.layerIndex = index;
}
/**
 * 审核不通过
 */
OrgInfoInfoDlg.refuse= function() {

    var joinId = $("#joinId").val();
    var reason = $("#reason").val();
    var userId = $("#userId").val();
    var mylay = parent.layer.getFrameIndex(window.name);
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/orgInfo/refuse?reason="+reason+"&id="+joinId+"&userId="+userId, function(data){
        Feng.success("修改成功!");
        //parent.layer.closeAll();
        //layer.closeAll();
        parent.layer.close(mylay);
        //window.parent.parent.OrgInfo.refuse();
        //parent.layer.close(mylay);
        //window.parent.OrgInfo.table.refresh();
        //OrgInfoInfoDlg.close();
        //layer.close(a);
        //window.location.href = location.href;
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.orgInfoInfoData);
    ajax.start();
}

$(function() {

});